/*
 * @(#)EventDAO.java
 * Copyright (c) 2011 TravelSky Technology Ltd. All Right Reserved. 
 */
package com.meetingshow.privilege.dao;

import java.util.List;

import com.meetingshow.common.base.dao.BaseDAO;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.privilege.dao.model.EventPO;

public class EventDAO extends BaseDAO {

    public void saveEvent(EventPO eventPO) throws Exception {
        this.saveBaseObj(eventPO);
    }

    public void updateEvent(EventPO eventPO) throws Exception {
        this.updateBaseObj(eventPO);
    }

    public void removeEvent(EventPO eventPO) throws Exception {
        this.deleteBaseObj(eventPO);
    }
    
    public EventPO getEventById (java.lang.Integer eventId) throws Exception {
        return this.queryById(EventPO.class, eventId);
    }

    public QueryResults<EventPO> queryEvent(QueryStruct queryStruct) throws Exception {
        QueryResults<EventPO> queryResults = new QueryResults<EventPO>();
        List<EventPO> resultList = findByParameter(queryStruct);
        queryResults.setResultList(resultList);
        if (queryStruct.getFirstResultNo() != null
                && queryStruct.getResultsPerGroup() != null) {
            queryResults = queryPageInfo(queryStruct, queryResults);
        } else {
            queryResults.setTotalResultsNum(Long.valueOf(resultList.size()));
        }
        return queryResults;
    }
}